package com.hou.mqacting.receiver;

import com.hou.mqacting.pojo.User;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 消息接受
 */
@Component
public class MessageReceiver {

//    @RabbitListener(queues = {"${rabbit.queue.string}"})
//    public void receiverString(String message){
//        System.out.println("接受到字符串消息:"+message);
//    }

    @RabbitListener(queues = {"${rabbit.queue.object}"})
    public void receiverObject(User user){
        System.out.println("接受到对象消息:"+user.toString());
    }

//    @RabbitListener(queues = {"testQueue"})
//    public void receiverTest(Message message){
//        //获取标识,推送消息结果时添加
//        message.getMessageProperties().getCorrelationId();
//        message.getBody();//获取消息内容
//        System.out.println("接受到消息:"+message);
//        //重新推送结果到回调队列
//    }


    //接受优先级消息
//    @RabbitListener(queues = {"preQueue1"})
//    public void receiverpreQueue1(String message){
//        System.out.println("接受到消息:"+message);
//    }
//
//    @RabbitListener(queues = {"preQueue2"})
//    public void receiverpreQueue2(String message){
//        System.out.println("接受到消息:"+message);
//    }

}

